import sys

loaderPath = str(sys.argv[1])
appPacPath = str(sys.argv[2])
targetPath = str(sys.argv[3])

#print loaderPath
#print appPacPath
#print targetPath

try:
    target = open(targetPath, "wb")
except:
    print "open target file failed, make sure you have writing permission \
        in current directory!"
    target.close()
    exit(1)

try:        
    loader = open(loaderPath, "rb")
    appPac = open(appPacPath, "rb")
except:
    print "open input file failed, make sure you have properly specified the \
        file path or reading permission!"
    loader.close()
    appPac.close()
    exit(1)

dataStream = loader.read() + appPac.read()

appPac.close()
loader.close()

target.write(dataStream)
target.close()

exit(0)
